﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using MaxLeaf.DB;
using System.Data;
using MySql.Data.MySqlClient;

namespace MaxLeaf.DAL.Web
{
    /// <summary>
    /// 部门
    /// </summary>
    public class t_departmentDAL : BaseDAL
    {
        public t_departmentDAL()
            : base()
        {
            strTableName = "mary_t_Department";
            strKeyFieldName = "FItemID";
            strFieldNames = "FBrNO,FManager,FPhone,FFax,FNote,FNumber,FName,FParentID,FDeleted,FShortNumber";
        }
        protected override DataTable DAL_GetData(DBAccess dbOrgCon, DBAccess destCon, int intdataType, object objParam)
        {
            GetDataType dataType = (GetDataType)intdataType;

            if (dataType == GetDataType.OrgData)
            {
                return GetT_Department(dbOrgCon,CvtFunc.ToString(objParam));
            }

            return base.DAL_GetData(dbOrgCon, destCon, intdataType, objParam);
        }



        internal string FDepartmentID(DBAccess dbOrgCon, DBAccess dbDestCon, string strOrgFDepartmentID)
        {
            if (strOrgFDepartmentID.Equals("0") || strOrgFDepartmentID.Length == 0)
            {
                return "";
            }

            Update(dbOrgCon, dbDestCon, strOrgFDepartmentID);

            return strOrgFDepartmentID;
        }

        private DataTable GetT_Department(DBAccess dbOrgCon, string strFItemID)
        {
            DataTable dtT_Department = null;
            if (dtT_Department == null)
            {
                dtT_Department = dbOrgCon.GetTableData("T_Department", new Dictionary<string, object> { { "FItemID", strFItemID } });

            }
            return dtT_Department;
        }
    }
}